package com.scorekeeper.objects;

import android.os.Parcel;
import android.os.Parcelable;

import com.scorekeeper.utils.DBProvider;

public class Division implements Parcelable {
	public int _id;
	public String name;
	public String acro;
	
	public Division() {
		this._id = -1;
	}
	
	public void save() {
		DBProvider db = new DBProvider();
		
		if (this._id != -1) {
			//update
			db.updateObject(DBProvider.Table.DIVISION, this);
		} else {
			//insert
			db.saveObject(DBProvider.Table.DIVISION, this);
		}
	}
	
	public int describeContents() { return hashCode(); }
	
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeLong(this._id);
		dest.writeString(this.name);
		dest.writeString(this.acro);
	}
	
	public void loadFromParcel(Parcel loadFrom) {
		this._id = loadFrom.readInt();
		this.name = loadFrom.readString();
		this.acro = loadFrom.readString();
	}
}